package com.chance.cc.crawler.development.bootstrap.du;

import com.alibaba.fastjson.JSON;
import com.chance.cc.crawler.core.downloader.HttpConfig;
import com.chance.cc.crawler.core.downloader.HttpPage;
import com.chance.cc.crawler.core.downloader.HttpRequest;
import com.chance.cc.crawler.core.downloader.HttpRequestBody;
import com.chance.cc.crawler.core.downloader.http.HttpClientDownloader;
import com.chance.cc.crawler.core.downloader.http.HttpClientGenerator;
import com.chance.cc.crawler.core.downloader.proxy.Proxy;
import com.chance.cc.crawler.core.downloader.proxy.SiteConfigProxyProvider;
import com.chance.cc.crawler.core.selector.Json;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

import static com.chance.cc.crawler.core.script.crawler.CrawlerScript.$_type;
import static org.codehaus.groovy.runtime.EncodingGroovyMethods.md5;

/**
 * @author bx
 * @date 2021/3/8 0008 13:41
 */
public class DUWXAPITest {
    public static Logger log = LoggerFactory.getLogger(DUWXAPITest.class);

    private static Proxy proxy = new Proxy();

    static {
        //代理配置
        proxy.setHost("http-dyn.abuyun.com");
        proxy.setPort(9020);
        proxy.setUsername("HL89Q19E86E2987D");
        proxy.setPassword("71F33D94CE5F7BF2");
    }

//    static {
//        //代理配置
//        proxy.setHost("http-cla.abuyun.com");
//        proxy.setPort(9030);
//        proxy.setUsername("H3487178Q0I1HVPC");
//        proxy.setPassword("ACE81171D81169CA");
//    }

//    static List<String> useragents = new ArrayList<>();
//    static {
//        HttpConfig httpConfig = HttpConfig.me("test");
//        HttpClientDownloader downloader = new HttpClientDownloader();
//        downloader.setClientGenerator(new HttpClientGenerator());
//        downloader.setProxyProvider(new SiteConfigProxyProvider());
//        HttpRequest httpRequest = new HttpRequest();
//        httpRequest.setUrl("https://fake-useragent.herokuapp.com/browsers/0.1.11");
//        HttpPage download = downloader.download(httpRequest, httpConfig);
//        String rawText = download.getRawText();
//        Json json = new Json(rawText);
//        useragents.addAll(json.jsonPath("$.browsers.chrome").all());
//        useragents.addAll(json.jsonPath("$.browsers.opera").all());
//        useragents.addAll(json.jsonPath("$.browsers.firefox").all());
//        useragents.addAll(json.jsonPath("$.browsers.internetexplorer").all());
//        useragents.addAll(json.jsonPath("$.browsers.safari").all());
//    }

    private static int count = 0;
    public static void main(String[] args) throws IOException {



        LinkedBlockingQueue<String> spuIds = getSpuIds();
        LinkedBlockingQueue<String> uas = getUserAgents();
        List<String> ipProxys = new ArrayList<>();
        ipProxys.add("183.23.74.56");


        for (int i = 1; i <= 10; i++) {

//            Proxy proxy = new Proxy();
////        //代理配置
//            proxy.setHost(ipProxys.get(i-1));
//            proxy.setPort(57114);
//            proxy.setUsername("15301929770");
//            proxy.setPassword("chancedata123");

            HttpConfig httpConfig = HttpConfig.me("test");

            httpConfig.setProxy(proxy);
            httpConfig.setUseProxy(true);
//        httpConfig.setDisableCookie(true);

            HttpClientDownloader downloader = new HttpClientDownloader();
            downloader.setClientGenerator(new HttpClientGenerator());
            downloader.setProxyProvider(new SiteConfigProxyProvider());



            new Thread(new TestDetailRun(downloader, httpConfig,spuIds,uas), "thread_" + i).start();
        }

//        testSign();
        testSign1();
    }

    private static void testSign(){
        String url = "https://app.dewu.com/api/v1/h5/search/fire/search/list?sign=04f60cad15380d1bbadd1f8ad279fa5b&title=&page=0&sortType=0&sortMode=1&limit=20&showHot=1&isAggr=1&catId=1&unionId=144";

        List<NameValuePair> parameters = URLEncodedUtils.parse(url.split("\\?")[1], Charset.forName("utf-8"));
        Map<String,Object> params = new HashMap<>();
        for (NameValuePair parameter : parameters) {
            params.put(parameter.getName(),parameter.getValue());
        }
        String sign = genSignature(params);
        log.info("du search product :" + sign);
    }

    private static void testSign1() throws UnsupportedEncodingException {
//        String paramStr = "{\"sign\":\"727d6b1c0e11a83fc6c77229f113e90d\",\"brandId\":144,\"lastId\":\"10000\",\"sortType\":1,\"sortMode\":1,\"limit\":20,\"categoryIds\":[],\"debugAgg\":true,\"aggregation\":true}";
//        Map params = new Json(paramStr).toObject(Map.class);


        Map<String,Object> params = new HashMap<>();
        params.put("recommendId","1017861");
        params.put("pageSize","10");
        params.put("pageNum",1);
        params.put("spuIds",new ArrayList<>());

        Map<String,Object> aggregationMap = new LinkedHashMap<>();
        aggregationMap.put("aggregation",true);
        aggregationMap.put("sortType",0);
        aggregationMap.put("sortMode",1);

        Map<String,String> filtersMap = new HashMap<>();
        aggregationMap.put("filters",filtersMap);
        params.put("aggregation",aggregationMap);


        String sign = genSignature(params);
        log.info("du search product :" + sign);
    }

    static class TestSearchRun implements Runnable {

        HttpClientDownloader downloader;
        HttpConfig httpConfig;

        static String searchUrlFormat = "https://app.dewu.com/api/v1/h5/search/fire/search/list?title=%s&page=%d&sortType=0&sortMode=1&limit=20&showHot=1&isAggr=1";
        static String productDetailUrl = "https://app.dewu.com/api/v1/h5/index/fire/flow/product/detail"; //商品明细url
        static String categoryDetail = "https://app.dewu.com/api/v1/h5/commodity/fire/search/doCategoryDetail"; //分类url

        static String seriesBrandUrl = "https://app.dewu.com/api/v1/h5/search/fire/commodity/detail_brand";

        public TestSearchRun(HttpClientDownloader downloader, HttpConfig httpConfig) {
            this.downloader = downloader;
            this.httpConfig = httpConfig;
        }

        @Override
        public void run() {

            int page = 0;
            int count = 0;
            while (true) {
                String requestUrl = null;
                try {
                    requestUrl = String.format(searchUrlFormat, URLEncoder.encode("冰淇淋","utf-8"),page);
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                List<NameValuePair> parameters = URLEncodedUtils.parse(requestUrl.split("\\?")[1], Charset.forName("utf-8"));
                Map<String,Object> params = new HashMap<>();
                for (NameValuePair parameter : parameters) {
                    params.put(parameter.getName(),parameter.getValue());
                }
                String sign = genSignature(params);
                log.info("du search product :" + sign);
                requestUrl = requestUrl + "&sign="+sign;

                HttpRequest httpRequest = new HttpRequest();
                httpRequest.setUrl(requestUrl);
                httpRequest.addHeader("appid","wxapp");
                HttpPage download = downloader.download(httpRequest, httpConfig);
                Json json = new Json(download.getRawText());
                String total = json.jsonPath($_type + ".data.total").get();
                if(StringUtils.isBlank(total) || total.equals("0")){
                    break;
                }
                try {
                    List<String> productList = json.jsonPath($_type + ".data.productList").all();
                    for (String product : productList) {
                        count++;
                        Json productJson = new Json(product);
                        String spuId = productJson.jsonPath($_type + ".spuId").get();

                        HttpRequest productRequest = new HttpRequest();
                        productRequest.setUrl(productDetailUrl);
                        productRequest.addHeader("appid","wxapp");
                        productRequest.addHeader("content-type","application/json");
                        productRequest.setMethod("POST");

                        Map<String,Object> productParams = new HashMap<>();
                        productParams.put("spuId",spuId);
                        productParams.put("productSourceName","");
                        productParams.put("propertyValueId","0");
                        String productSign = genSignature(productParams);
                        log.info("du article sign :{}",productSign);
                        productParams.put("sign",productSign);
                        HttpRequestBody httpRequestBody = HttpRequestBody.json(JSON.toJSONString(productParams), "utf-8");
                        productRequest.setRequestBody(httpRequestBody);

                        HttpPage productHttpPage = downloader.download(productRequest,httpConfig);
                        log.info("du article detail :{}",productHttpPage.getRawText());

                    }
                    page++;
                } catch (Exception e) {
                    log.error("du search page download error :{},page rawText {}",e.getMessage(),download.getRawText());
                    break;
                }
            }

            System.out.println("total count:"+count);


//            String params = "{\"sign\":\"f6466ea2046d118d0e7cc2d495c0855a\",\"brandId\":144,\"lastId\":\"0\",\"sortType\":1,\"sortMode\":1,\"limit\":20,\"categoryIds\":[],\"debugAgg\":true,\"aggregation\":true}";
//            String paramStr = "{\"sign\":\"c151ef2df84122cab84817ebdabe49ad\",\"spuId\":\"9670\",\"productSourceName\":\"\",\"propertyValueId\":\"0\"}";
//            params = new Json(paramStr).toObject(Map.class);

//            String url = "https://www.xiaohongshu.com/api/sns/v10/search/notes?" + URLEncodedUtils.format(nameValuePairs, "utf-8");
//            HttpRequest httpRequest = new HttpRequest();

//            for (int i = 0; i < 1; i++) {
//
//
//
//            }
        }

        private void crawlerCategoryDetail(){
            // 潮鞋
            crawlerShoesDetail();

            // 朝服
            crawlerClothesDetail();
        }

        private void crawlerShoesDetail(){
            HttpRequest productRequest = new HttpRequest();
            productRequest.setUrl(categoryDetail);
            productRequest.addHeader("appid","wxapp");
            productRequest.addHeader("content-type","application/json");
            productRequest.setMethod("POST");

            Map<String,Object> productParams = new HashMap<>();
            productParams.put("catId","3");
            String productSign = genSignature(productParams);
            productParams.put("sign",productSign);
            HttpRequestBody httpRequestBody = HttpRequestBody.json(JSON.toJSONString(productParams), "utf-8");
            productRequest.setRequestBody(httpRequestBody);

            HttpPage shoesHttpPage = downloader.download(productRequest,httpConfig);
//            Json shoesJson = new Json(shoesHttpPage.getRawText());
//            List<String> shoesList = shoesJson.jsonPath($_type + ".data.list").all();
//            for (String shoes : shoesList) {
//                Json shoesCategory = new Json(shoes);
//                String brandName = shoesCategory.jsonPath($_type + ".brand.brandName").get();
//                String brandType = shoesCategory.jsonPath($_type + ".brand.type").get();
//                if ("999".equals(brandType)){ //为你推荐
//                    List<String> seriesList = shoesCategory.jsonPath(".seriesList").all();
//                    for (String series : seriesList) {
//                        Json seriesJson = new Json(series);
//                        String cn = seriesJson.jsonPath($_type + ".cn").get();
//                        if ("brand".equals(cn)){ // https://app.dewu.com/api/v1/h5/search/fire/commodity/detail_brand
//                            HttpRequest httpRequest = new HttpRequest();
//                            httpRequest.setUrl(seriesBrandUrl);
//                            httpRequest.addHeader("appid","wxapp");
//                            httpRequest.addHeader("content-type","application/json");
//                            httpRequest.setMethod("POST");
//
//
//                        }
//                    }
//                }
//                log.info("shoes category brand name :{}",brandName);
//            }
        }

        private void crawlerClothesDetail(){

        }
    }


    static class TestDetailBrandRun implements Runnable {

        HttpClientDownloader downloader;
        HttpConfig httpConfig;

        Set<String> spuids = new HashSet<>();
        static String seriesBrandUrl = "https://app.dewu.com/api/v1/h5/search/fire/commodity/detail_brand";

        public TestDetailBrandRun(HttpClientDownloader downloader, HttpConfig httpConfig) {
            this.downloader = downloader;
            this.httpConfig = httpConfig;
        }

        @Override
        public void run() {

            String page = "0";
            int count = 1;
            while (true) {
                log.info("采集当前页为：{}", count);
                if (count > 255) {
                    break;
                }
                count++;
                Map<String, Object> productParams = new HashMap<>();
                productParams.put("brandId", "144");
                productParams.put("lastId", page);
                productParams.put("sortType", 0);
                productParams.put("sortMode", 1);
                productParams.put("limit", 20);
                productParams.put("categoryIds", new ArrayList<>());
                productParams.put("debugAgg", true);
                productParams.put("aggregation", true);
                String sign = genSignature(productParams);
                productParams.put("sign", sign);
                log.info("du search product :" + sign);

                HttpRequest httpRequest = new HttpRequest();
                httpRequest.setUrl(seriesBrandUrl);
                httpRequest.addHeader("appid", "wxapp");
                httpRequest.addHeader("content-type", "application/json");
                httpRequest.setMethod("POST");
                HttpRequestBody requestBody = HttpRequestBody.json(JSON.toJSONString(productParams), "utf-8");
                httpRequest.setRequestBody(requestBody);

                HttpPage download = null;
                try {
                    download = downloader.download(httpRequest, httpConfig);
                    Json json = new Json(download.getRawText());
                    List<String> all = json.jsonPath($_type + ".data.itemList").all();
                    page = json.jsonPath($_type + ".data.lastId").get();
                    for (String item : all) {
                        Json itemJson = new Json(item);
                        String spuId = itemJson.jsonPath($_type + ".spuId").get();
                        String title = itemJson.jsonPath($_type + ".title").get();
                        http://15301929770.v4.dailiyun.com/query.txt?key=NPDD5F9792&word=&count=1&rand=false&ltime=600&norepeat=true&detail=true
                        if (!spuids.contains(spuId)) {
                            spuids.add(spuId);
                            continue;
                        }

                        log.warn("重复记录：{}，page：{}", spuId + "-->" + title, page);
                    }
                } catch (Exception e) {
//                   continue;
                }

            }

            for (String spuid : spuids) {
                log.info("采集记录：{}", spuid);
            }

            log.info("采集总量：{}", spuids.size());

//            String params = "{\"sign\":\"f6466ea2046d118d0e7cc2d495c0855a\",\"brandId\":144,\"lastId\":\"0\",\"sortType\":1,\"sortMode\":1,\"limit\":20,\"categoryIds\":[],\"debugAgg\":true,\"aggregation\":true}";
//            String paramStr = "{\"sign\":\"c151ef2df84122cab84817ebdabe49ad\",\"spuId\":\"9670\",\"productSourceName\":\"\",\"propertyValueId\":\"0\"}";
//            params = new Json(paramStr).toObject(Map.class);

//            String url = "https://www.xiaohongshu.com/api/sns/v10/search/notes?" + URLEncodedUtils.format(nameValuePairs, "utf-8");
//            HttpRequest httpRequest = new HttpRequest();

//            for (int i = 0; i < 1; i++) {
//
//
//
//            }
        }

    }

    static class TestDetailRun implements Runnable {

        HttpClientDownloader downloader;
        HttpConfig httpConfig;
        LinkedBlockingQueue<String> spuIds;
        LinkedBlockingQueue<String> uas;

        static String seriesBrandUrl = "https://app.dewu.com/api/v1/h5/index/fire/flow/product/detail";

        public TestDetailRun(HttpClientDownloader downloader, HttpConfig httpConfig,LinkedBlockingQueue<String> spuIds,LinkedBlockingQueue<String> uas) {
            this.downloader = downloader;
            this.httpConfig = httpConfig;
            this.spuIds = spuIds;
            this.uas = uas;
        }

        @Override
        public void run() {

            int totalDownload = 0;
            int successDownload = 0;
            int failDownload = 0;
            httpConfig.setResponseTextGenerateHtml(false);
            log.info("http config {}",JSON.toJSONString(httpConfig));
            String spuId;
            try {
                spuId = spuIds.poll(3, TimeUnit.SECONDS);
                while (StringUtils.isNotBlank(spuId)) {
                    totalDownload++;
                    String ua = uas.poll();
                    uas.add(ua);
                    boolean isSuccess = downloadProductDetail(spuId,downloader,httpConfig,ua);
                    if (isSuccess){
                        successDownload++;
                    } else {
                        failDownload++;
                    }
                    spuId = spuIds.poll(3, TimeUnit.SECONDS);
                    log.info("totalDownload:{},successDownload:{},failDownload:{}",totalDownload,successDownload,failDownload);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }

    private static LinkedBlockingQueue<String> getSpuIds() throws IOException {
        List<String> lines = IOUtils.readLines(new FileInputStream("C:\\Users\\Administrator\\Desktop\\jar\\org\\du_app.json"), "utf-8");
        LinkedBlockingQueue<String> spuIds = new LinkedBlockingQueue<>();
        for (String line : lines) {
            Json lineJson = new Json(line);
            String spuId = lineJson.jsonPath("spuId").get();
            spuIds.add(spuId);

        }
        return spuIds;
    }

    private static LinkedBlockingQueue<String> getUserAgents() throws IOException {
        List<String> lines = IOUtils.readLines(new FileInputStream("C:\\Users\\Administrator\\Desktop\\jar\\org\\phone.txt"), "utf-8");
        LinkedBlockingQueue<String> uas = new LinkedBlockingQueue<>();
        uas.addAll(lines);
        return uas;
    }

    private static boolean downloadProductDetail(String spuId,HttpClientDownloader downloader, HttpConfig httpConfig,String ua){

        String seriesBrandUrl = "https://app.dewu.com/api/v1/h5/index/fire/flow/product/detail";
        Map<String,Object> productParams = new HashMap<>();
        productParams.put("productSourceName","");
        productParams.put("propertyValueId","0");
        productParams.put("spuId",spuId);
        String sign = genSignature(productParams);
        productParams.put("sign",sign);
        log.info("du search product :" + sign);

        HttpRequest httpRequest = new HttpRequest();
        httpRequest.setUrl(seriesBrandUrl);
        httpRequest.addHeader("appid","wxapp");
        httpRequest.addHeader("AppId","wxapp");
        httpRequest.addHeader("platform","h5");
        httpRequest.addHeader("Referer","https://servicewechat.com/wx3c12cdd0ae8b1a7b/238/page-frame.html");
        httpRequest.addHeader("Accept-Encoding","gzip,compress,br,deflate");
        httpRequest.addHeader("wxapp-login-token","");
        httpRequest.addHeader("appversion","4.4.0");
//        httpRequest.addHeader("User-Agent","Mozilla/5.0 (Linux; Android 8.0.0; MI 5s Build/OPR1.170623.032; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2885 MMWEBSDK/20210601 Mobile Safari/537.36 MMWEBID/6446 MicroMessenger/8.0.7.1920(0x28000753) Process/appbrand0 WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android");
        httpRequest.addHeader("User-Agent",ua);
        httpRequest.addHeader("content-type","application/json");
        httpRequest.addHeader("charset","utf-8");
        httpRequest.addHeader("Host","app.dewu.com");
        httpRequest.setMethod("POST");
        HttpRequestBody requestBody = HttpRequestBody.json(JSON.toJSONString(productParams), "utf-8");
        httpRequest.setRequestBody(requestBody);

        HttpPage download = null;
        try {
            download = downloader.download(httpRequest, httpConfig);
            log.info("http status code:"+download.getStatusCode());
            if (download.isDownloadSuccess() && download.getStatusCode() == 200){
                log.info("success result:"+download.getRawText());
                log.error("success ua {}",httpRequest.getHeaders().get("User-Agent"));
                List<String> all = download.getJson().jsonPath("data.image.spuImage.images[*].url").all();
                for (String img : all) {
                    HttpRequest imgHttpRequest = new HttpRequest();
                    imgHttpRequest.setUrl(img);
                    imgHttpRequest.addHeader("appid","wxapp");
                    imgHttpRequest.addHeader("platform","h5");
                    imgHttpRequest.addHeader("content-type","application/json");
                    imgHttpRequest.setRequestBody(requestBody);
                    downloader.download(imgHttpRequest, httpConfig);
                }
            } else {
                log.error("error ua {}",httpRequest.getHeaders().get("User-Agent"));
                return false;
            }
//                    HttpRequest currentIPRequest = new HttpRequest();
//                    currentIPRequest.setUrl("http://proxy.abuyun.com/current-ip");
//                    HttpPage httpPage = downloader.download(currentIPRequest, httpConfig);
//                    System.out.println("current ip:" + httpPage.getRawText().trim());
        } catch (Exception e) {
            log.error(e.getMessage());
            return false;
        }
        return true;
    }

    static class TestSearchCommentRun implements Runnable {

        HttpClientDownloader downloader;
        HttpConfig httpConfig;

        Set<String> spuids = new HashSet<>();
        static String seriesBrandUrl = "https://app.dewu.com/api/v1/h5/search/fire/search/list?" +
                "title=nike&page=%d&sortType=0&sortMode=1&limit=20&showHot=-1&isAggr=1&catId=1";

        public TestSearchCommentRun(HttpClientDownloader downloader, HttpConfig httpConfig) {
            this.downloader = downloader;
            this.httpConfig = httpConfig;
        }

        @Override
        public void run() {

            String page = "0";
            int count = 0;
            while (true) {
                log.info("采集当前页为：{}",count);
                if (count > 255){
                    break;
                }

                String searchUrl = String.format(seriesBrandUrl, count);
                count ++;

                List<NameValuePair> parameters = URLEncodedUtils.parse(searchUrl.split("\\?")[1], Charset.forName("utf-8"));
                Map<String,Object> params = new HashMap<>();
                for (NameValuePair parameter : parameters) {
                    params.put(parameter.getName(),parameter.getValue());
                }
                String sign = genSignature(params);
                searchUrl = searchUrl + "&sign=" + sign;

                HttpRequest httpRequest = new HttpRequest();
                httpRequest.setUrl(searchUrl);
                httpRequest.addHeader("appid","wxapp");

                HttpPage download = null;
                try {
                    download = downloader.download(httpRequest, httpConfig);
                    Json json = new Json(download.getRawText());
                    List<String> all = json.jsonPath($_type + ".data.productList").all();
//                    page = json.jsonPath($_type + ".data.lastId").get();
                    for (String item : all) {
                        Json itemJson = new Json(item);
                        String spuId = itemJson.jsonPath($_type + ".spuId").get();
                        String title = itemJson.jsonPath($_type + ".title").get();

                        if (!spuids.contains(spuId)){
                            spuids.add(spuId);
                            continue;
                        }

                        log.warn("重复记录：{}，page：{}",spuId+"-->"+title,page);
                    }
                } catch (Exception e) {
//                   continue;
                }

            }

            for (String spuid : spuids) {
                log.info("采集记录：{}",spuid);
            }

            log.info("采集总量：{}",spuids.size());
        }

    }

    public static String genSignature(Map<String,Object> params) {
        if(params == null){
            return null;
        }
        String sign = "";
        StringBuffer sb = new StringBuffer();
        try {
            // 1. 字典升序排序
            SortedMap<String,Object> sortedMap = new TreeMap<>(params);
            // 2. 拼按URL键值对
            Set<String> keySet = sortedMap.keySet();
            for(String key : keySet){
                //sign不参与算法
                if(key.equals("sign")){
                    continue;
                }

                Object obj =  sortedMap.get(key);
                String value = obj.toString() ;
                if (obj instanceof Map){
                    value = JSON.toJSONString(obj);
                }
                if (obj instanceof List){
                    List list = (List) obj;
                    value = "";
                    for (Object o : list) {
                        if (value.length() > 0){
                            value += ",";
                        }
                        value += JSON.toJSONString(o);
                    }
//                    value = ","+JSON.toJSONString(obj);
                }
                if ("[]".equals(value)){
                    value = "";
                }
                sb.append(key).append(value);

            }
            String uriString = sb.toString() + "19bc545a393a25177083d4a748807cc0";
//            String uriString = sb.toString() + "048a9c4943398714b356a696503d2d36";
            // 3. MD5运算得到请求签名
            sign = md5(uriString);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sign;
    }
}
